# !/usr/bin/env python
# -*- coding:utf-8 -*-
# project name: CP_Automation
# author: "Lei Yong" 
# creation time: 2018/6/28 14:18
# Email: leiyong711@163.com

import unittest
from Operation.element import Element
from selenium.webdriver.common.keys import Keys
import time
import os

el = Element()


class Test(unittest.TestCase):
    """厅主后台-财务管理-人工存提"""

    @classmethod
    def setUpClass(cls):
        cls.driver = el.Driver()
        el.windowMax()

    def test01(self):
        """登录厅主后台"""
        el.openurl('http://192.168.1.190/mayi-Backstage/#/login')
        el.windowMax()
        el.name('username').clear()
        el.name('password').clear()
        el.name('username').send_keys('leiyong')
        el.name('password').send_keys('leiyong')
        el.css(".login-button").click()
        self.assertTrue(el.trywait_assert_xpath("//span[text()='商户管理平台']", 5), '登录失败')

    def test02(self):
        """增加余额-所有用户-可提现余额"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'财务管理')]").click()
        time.sleep(1)
        el.text('人工存提').click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'所有用户')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test03(self):
        """增加余额-指定用户-可提现余额"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'指定用户')]").click()
        el.css('.up-btn').click()
        os.system("%s/WinScript/chrome_upload.exe" % os.path.dirname(os.path.realpath(__file__))[:-5])
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test04(self):
        """增加余额-用户等级-可提现余额"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'用户等级')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'黄金VIP')]").click()
        time.sleep(0.5)
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test05(self):
        """增加余额-所有用户-彩金"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'所有用户')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'彩金')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test06(self):
        """增加余额-指定用户-彩金"""
        time.sleep(2)
        el.xpath("//span[contains(text(),'指定用户')]").click()
        el.css('.up-btn').click()
        os.system("%s/WinScript/chrome_upload.exe" % os.path.dirname(os.path.realpath(__file__))[:-5])
        el.xpath("//span[contains(text(),'彩金')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test07(self):
        """增加余额-用户等级-彩金"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'用户等级')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'黄金VIP')]").click()
        time.sleep(0.5)
        el.xpath("//span[contains(text(),'彩金')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    # 减少余额
    def test08(self):
        """减少余额-所有用户-可提现余额"""
        time.sleep(1)
        el.css('.check-li li:nth-of-type(2)').click()
        time.sleep(1)
        el.text('人工存提').click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'所有用户')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test09(self):
        """减少余额-指定用户-可提现余额"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'指定用户')]").click()
        el.css('.up-btn').click()
        os.system("%s/WinScript/chrome_upload.exe" % os.path.dirname(os.path.realpath(__file__))[:-5])
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test10(self):
        """减少余额-用户等级-可提现余额"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'用户等级')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'黄金VIP')]").click()
        time.sleep(0.5)
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test11(self):
        """减少余额-所有用户-彩金"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'所有用户')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'彩金')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test12(self):
        """减少余额-指定用户-彩金"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'指定用户')]").click()
        el.css('.up-btn').click()
        os.system("%s/WinScript/chrome_upload.exe" % os.path.dirname(os.path.realpath(__file__))[:-5])
        el.xpath("//span[contains(text(),'彩金')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test13(self):
        """减少余额-用户等级-彩金"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'用户等级')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'黄金VIP')]").click()
        time.sleep(0.5)
        el.xpath("//span[contains(text(),'彩金')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    # 手工返点
    def test14(self):
        """手工返点-所有用户-可提现余额"""
        time.sleep(1)
        el.css('.check-li li:nth-of-type(3)').click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'所有用户')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test15(self):
        """手工返点-指定用户-可提现余额"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'指定用户')]").click()
        el.css('.up-btn').click()
        os.system("%s/WinScript/chrome_upload.exe" % os.path.dirname(os.path.realpath(__file__))[:-5])
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')

    def test16(self):
        """手工返点-用户等级-可提现余额"""
        time.sleep(1)
        el.xpath("//span[contains(text(),'用户等级')]").click()
        time.sleep(1)
        el.xpath("//span[contains(text(),'黄金VIP')]").click()
        time.sleep(0.5)
        el.xpath("//span[contains(text(),'可提现余额')]").click()
        el.id('amount').send_keys('2')
        time.sleep(1)
        el.xpath('html/body/div[1]/div/div/div[2]/div[2]/div/div/div[2]/div/div/div/div[3]/button').click()
        self.assertTrue(el.trywait_assert_xpath("//span[contains(text(),'提交成功')]", 5), '提交失败')



    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()
